#pragma once

#define MAX_ITEMS 50

class CMLSChain
{
	enum MLSChainError
	{
		mlsce_None = 0
		,mlsce_File = 1
		,mlsce_BigChain = 2
		,mlsce_Prev = 3
		,mlsce_Last = 4
	};
	static CString ErrMsg[];

	struct MLSChainItem
	{
		CString thisname;
		CString prevname;
		CString nextname;
		int prev;
		int next;
		MLSChainItem(CString iname):thisname(iname),prev(-1),next(-1){}
	};
public:
	// Contructors & Destructor
	CMLSChain(void);
	CMLSChain(CString istart);
	virtual ~CMLSChain(void);
	// Operations
	void Clean(void);
	BOOL LoadChain();
	int Find(CString FileName);
	// Attributes
	void SetStartDoc(CString value);
	int GetCount(){return Count;}
	CString GetError();
	CString GetItem(int n){return pItem[n]->thisname;}
	CString GetItemPath(int n){return DocsPath+pItem[n]->thisname;}
	CString GetItemPrev(int n){return pItem[n]->prevname;}
	CString GetItemNext(int n){return pItem[n]->nextname;}
	BOOL MoveAll(CString TargetPath);
protected:
	BOOL CreateItem(int n,CString FilePath,CString FileName);
	BOOL CheckChain();
	CString StartDoc;
	CString DocsPath;
	MLSChainItem* pItem[MAX_ITEMS];
	int Count;
	MLSChainError Error;
};
